package pl.bristleback.server.bristle.config;

import pl.bristleback.server.bristle.binding.BindingsProcessor;
import pl.bristleback.server.bristle.binding.DefaultBindingsProcessor;
import pl.bristleback.server.bristle.binding.resolvers.BigDecimalPropertyResolver;
import pl.bristleback.server.bristle.binding.resolvers.BigIntegerPropertyResolver;
import pl.bristleback.server.bristle.binding.resolvers.BindingEngine;
import pl.bristleback.server.bristle.binding.resolvers.BooleanPropertyResolver;
import pl.bristleback.server.bristle.binding.resolvers.DefaultBindingEngine;
import pl.bristleback.server.bristle.binding.resolvers.DoublePropertyResolver;
import pl.bristleback.server.bristle.binding.resolvers.IntegerPropertyResolver;
import pl.bristleback.server.bristle.binding.resolvers.LongPropertyResolver;
import pl.bristleback.server.bristle.binding.resolvers.PropertyValueResolver;
import pl.bristleback.server.bristle.binding.resolvers.StringPropertyResolver;
import pl.bristleback.server.bristle.messages.MessageDispatcher;
import pl.bristleback.server.bristle.messages.SingleThreadedMessageDispatcher;
import pl.bristleback.server.bristle.token.JsonTokenizerEngine;
import pl.bristleback.server.bristle.token.TokenizerEngine;

/**
 * This is an enumeration of Bristleback configurable elements.
 * <p/>
 * Created on: 2011-03-27 12:18:09 <br/>
 *
 * @author Wojciech Niemiec
 */
public enum BristleConfigurationElement {

  /**
   * Configuration element used to process action class annotations. Name of the plugin setting: <code>'bristle.resolvers.action.classes'</code>, can be specified in in jwebsocket.xml file.
   */
  ACTION_ANNOTATION_PROCESSOR("bristle.resolvers.action.classes", ActionAnnotationsProcessor.class, PackageActionAnnotationsProcessor.class),

  /**
   * Class that will be used to dispatch messages. Can be specified by overriding plugin setting <code>'bristle.defaults.message.dispatcher'</code> in jwebsocket.xml file.
   */
  MESSAGE_DISPATCHER("bristle.defaults.message.dispatcher", MessageDispatcher.class, SingleThreadedMessageDispatcher.class),

  /**
   * Default {@link pl.bristleback.server.bristle.token.TokenizerEngine} implementation used in adding objects to tokens.
   * Can be specified by setting <code>'bristle.defaults.tokenizer'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_TOKENIZER("bristle.defaults.tokenizer", TokenizerEngine.class, JsonTokenizerEngine.class),

  /**
   * Default {@link pl.bristleback.server.bristle.binding.resolvers.BindingEngine} implementation.
   * Can be specified by setting <code>'bristle.defaults.binding.engine'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_BINDING_ENGINE("bristle.defaults.binding.engine", BindingEngine.class, DefaultBindingEngine.class),

  /**
   * Configuration element used to process binding annotations in action classes.
   * Can be specified by setting <code>'bristle.resolvers.bindings'</code> plugin property in jwebsocket.xml file.
   */
  BINDINGS_PROCESSOR("bristle.resolvers.bindings", BindingsProcessor.class, DefaultBindingsProcessor.class),

  /**
   * Configuration element used to retrieve message container (message dispatcher and message senders) along with assigning dispatcher and jwebsocket server to senders.
   * Can be specified by setting <code>'bristle.resolvers.message.container'</code> plugin property in jwebsocket.xml file.
   */
  MESSAGE_CONTAINER_RESOLVER("bristle.resolvers.message.container", MessageContainerResolver.class, MessageContainerDefaultResolver.class),

  /**
   * Default boolean value resolver, used in binding operations.
   * Can be specified by setting <code>'bristle.resolvers.property.boolean'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_VALUE_RESOLVER_BOOLEAN(BristleConfiguration.PROPERTY_VALUE_RESOLVER_PREFIX + "boolean", PropertyValueResolver.class, BooleanPropertyResolver.class),


  /**
   * Default integer value resolver, used in binding operations.
   * Can be specified by setting <code>'bristle.resolvers.property.integer'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_VALUE_RESOLVER_INTEGER(BristleConfiguration.PROPERTY_VALUE_RESOLVER_PREFIX + "integer", PropertyValueResolver.class, IntegerPropertyResolver.class),

  /**
   * Default integer value resolver, used in binding operations.
   * Can be specified by setting <code>'bristle.resolvers.property.long'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_VALUE_RESOLVER_LONG(BristleConfiguration.PROPERTY_VALUE_RESOLVER_PREFIX + "long", PropertyValueResolver.class, LongPropertyResolver.class),

  /**
   * Default integer value resolver, used in binding operations.
   * Can be specified by setting <code>'bristle.resolvers.property.double'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_VALUE_RESOLVER_DOUBLE(BristleConfiguration.PROPERTY_VALUE_RESOLVER_PREFIX + "double", PropertyValueResolver.class, DoublePropertyResolver.class),

  /**
   * Default String value resolver, used in binding operations.
   * Can be specified by setting <code>'bristle.resolvers.property.string'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_VALUE_RESOLVER_STRING(BristleConfiguration.PROPERTY_VALUE_RESOLVER_PREFIX + "string", PropertyValueResolver.class, StringPropertyResolver.class),

  /**
   * Default BigDecimal value resolver, used in binding operations.
   * Can be specified by setting <code>'bristle.resolvers.property.bigDecimal'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_VALUE_RESOLVER_BIG_DECIMAL(BristleConfiguration.PROPERTY_VALUE_RESOLVER_PREFIX + "bigDecimal", PropertyValueResolver.class, BigDecimalPropertyResolver.class),

  /**
   * Default BigInteger value resolver, used in binding operations.
   * Can be specified by setting <code>'bristle.resolvers.property.bigInteger'</code> plugin property in jwebsocket.xml file.
   */
  DEFAULT_VALUE_RESOLVER_BIG_INTEGER(BristleConfiguration.PROPERTY_VALUE_RESOLVER_PREFIX + "bigInteger", PropertyValueResolver.class, BigIntegerPropertyResolver.class);

  private Class interfaceToImplement;
  private Class defaultImplementationClass;
  private String pluginSettingName;

  BristleConfigurationElement(String pluginSettingName, Class interfaceToImplement, Class defaultImplementationClass) {
    this.defaultImplementationClass = defaultImplementationClass;
    this.interfaceToImplement = interfaceToImplement;
    this.pluginSettingName = pluginSettingName;
  }

  public Class<?> getInterfaceToImplement() {
    return interfaceToImplement;
  }

  public Class getDefaultImplementationClass() {
    return defaultImplementationClass;
  }

  public String getPluginSettingName() {
    return pluginSettingName;
  }
}
